//
//  DoctorDetailController.m
//  International_Hospital
//
//  Created by 统杰李 on 16/7/7.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "DoctorDetailController.h"
#import "DoctorApplyModel.h"
#import "PreDoctorCell.h"
#import "DetailInfoCell.h"
#import "PatientInfoCell.h"
#import "ApplyDoctor_FootView.h"

@interface DoctorDetailController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong)UITableView *tableView;

@property (nonatomic,strong)ApplyDoctor_FootView *footView;

@end

@implementation DoctorDetailController

#pragma mark
#pragma mark - 设置model
- (void)setModel:(DoctorApplyModel *)model{
    
    _model = model;
    
    [self.tableView reloadData];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupUI];

}

#pragma mark
#pragma mark - 设置界面UI
- (void)setupUI{
    
    //创建tableView
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.frame];
    
    self.tableView = tableView;
    self.tableView.scrollEnabled = NO;
    [self.view addSubview:tableView];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    //注册cell
    [self.tableView registerClass:[PatientInfoCell class] forCellReuseIdentifier:@"user"];
    [self.tableView registerClass:[PreDoctorCell class] forCellReuseIdentifier:@"doctor"];
    [self.tableView registerClass:[DetailInfoCell class] forCellReuseIdentifier:@"info"];

    //设置footView
    ApplyDoctor_FootView *footView = [[ApplyDoctor_FootView alloc] initWithFrame:(CGRectZero)];
    
    self.tableView.tableFooterView = footView;
    
    [self.tableView addSubview:footView];
    
    [footView makeConstraints:^(MASConstraintMaker *make) {
    
        make.left.equalTo(self.tableView.left).offset(10);
        make.width.equalTo(SCREEN_WIDTH - 20);
        make.height.equalTo(40);
        make.bottom.equalTo(self.tableView.top).offset(SCREEN_HEIGHT - 104);
        
    }];
}

#pragma mark
#pragma mark - 代理方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 5;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    DoctorApplyModel *model = self.model;
    
    if (indexPath.section == 0) {
        PatientInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"user" forIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        cell.statuStr = self.statuStr2;
        
        cell.model = model;
        
        return cell;
    }
    
    if (indexPath.section == 1){
        
        UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"yuyue"];
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.text = @"预约医生:";
        cell.textLabel.textColor = [UIColor lightGrayColor];
        cell.textLabel.font = [UIFont systemFontOfSize:20];
        
        return cell;
        
    }
    
    if (indexPath.section == 2) {
        PreDoctorCell *cell = [tableView dequeueReusableCellWithIdentifier:@"doctor" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.model = model;
        
        return cell;
    }
    
    if (indexPath.section == 3){
        
        UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"xuzhi"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.text = @"预约须知:";
        cell.textLabel.textColor = [UIColor lightGrayColor];
        cell.textLabel.font = [UIFont systemFontOfSize:20];
        
        return cell;
        
    }
    
    else{
        
        DetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"info" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.model = model;
        
        return cell;
    }

}

#pragma mark
#pragma mark - 设置cell行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0 && indexPath.row == 0) {
                return 90;
    }
    if (indexPath.section == 1 && indexPath.row == 0) {
        return 50;
    }
    if (indexPath.section == 2 && indexPath.row == 0) {
        return 90;
    }
    if (indexPath.section == 3 && indexPath.row == 0) {
        return 50;
    }
    if (indexPath.section == 4 && indexPath.row == 0) {
        return 100;
    }
    
    return 0;
}

@end
